// 节流：高频触发的时候，每隔一段时间触发一次

const throttle = (fn, wait = 100) => {
  let pre = 0;

  return (...args) => {
    let now = +new Date();
    if (now - pre > wait) {
      fn.apply(this, args);
      pre = now;
    }
  };
};

function logScroll() {
    console.log('滚动屏幕')
}

window.addEventListener('scroll', throttle(logScroll, 1000))